<?php
class Host extends AppModel {
	var $name = 'Host';
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $hasAndBelongsToMany = array(
		'Event' => array(
			'className' => 'Event',
			'joinTable' => 'event_hosts',
			'foreignKey' => 'host_id',
			'associationForeignKey' => 'event_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);
        
          var $validate = array(
        'business_name'=> array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank'
        ),

        'first_name'=> array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank'
        ),

        'last_name' => array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank'
        ),

        'passwd' => array(
            'rule' => array('notEmpty', true),
            'message' => 'This field cannot be left blank'
        ),

        'email_addr' => array(
            'rule' => 'email',
            'message' => 'Please supply a valid email address.'
        )

        );

          function  beforeValidate() {

            if ($this->find('count', array('conditions' => array('Host.email_addr' => $this->data['Host']['email_addr']))) > 0) {
                $this->invalidate('email_addr_unique');
                return false;
            } else {
                return true;
            }
            }

    
}
?>